<?php
namespace Admin\Controller;
use Think\Controller;

class CommonController extends Controller {
    public function _initialize(){
        //检测登陆
        if (!isset($_SESSION['username']) || $_SESSION['username'] == '') {
            $this->redirect('Admin/Login/login');
        }
         //判断用户是否有权限继续访问后台模块
        if (isset($_SESSION['type']) && $_SESSION['type'] == 0) {//存在 允许登陆
            $this->error('登陆成功但没有权限',U('Home/Index/index'),1);
        }
        /*
       //检测其他验证规则 
        //$rule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME);
        $rule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME);
        $uid = $_SESSION['userid'];
        $res = authcheck($rule,$uid,1,$mode='url');
        //p($rule,$uid,$res);
        if (!$res){
            //$this->redirect('Home/Index/index');
            //$this->error('没有权限',U('Home/Index/index'),1);
            $this->error('没有权限');
        }
        */
         
    }
}
?>
